package com.neuedu.servlet.business;

import cn.hutool.core.util.StrUtil;
import com.neuedu.service.BusinessService;
import com.neuedu.service.Imp.BusinessServiceImp;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


@WebServlet("/busRegist")
public class BusinessRegisterServlet extends HttpServlet {
    private BusinessService businessService = new BusinessServiceImp();

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // 规范浏览器携带数据的格式
        req.setCharacterEncoding("utf-8");


        String account = req.getParameter("account");
        String password = req.getParameter("password");
        String telephone = req.getParameter("telephone");
        String contact = req.getParameter("contact");

        if(StrUtil.isBlank(account) || StrUtil.isBlank(password) || StrUtil.isBlank(telephone) || StrUtil.isBlank(contact)){
            resp.getWriter().write(0 + "");
        }else{
            Integer i = businessService.addBus(account,password,telephone,contact);
            resp.getWriter().write(i + "");
        }


    }
}
